home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1985 October
/
Ahoy_Magazine_85-10_1985_Double_L.d64
/
molecular mot.
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
1KB
|
45 lines
0 rem << rr22-1 >>
1 rem
2 rem -- molecular motion --
3 rem rupert report #22
4 rem
6 rem movement of molecules from one
7 rem compartment to another
8 rem
9 :rem total # and # on left side:
10 ttl=480 : nl=480
15 l1$=chr$(157):l$=" "+l1$+l1$+" "
20 kk=1 : k1=1024 : k2=40
30 k3=32 : k4=81 :rem blank & molecule
35 :rem clear screen and set color:
40 poke 53281,0 : print chr$(147)
50 poke 53281,1 : print chr$(144)
55 :rem put 480 molecules on left:
60 for y=1 to 24 : for x=0 to 19
70 poke k1+x+k2*y,k4 : next : next
75 :rem ==== main loop ====
80 rl=nl/ttl :rem relative # on left
90 rn=rnd(0) :rem random number
100 if nl=480 and kk=-1 then 270
110 if rn<rl then pl=k3: pr=k4:goto 130
120 pl=k4 : pr=k3
130 x=int(rnd(0)*20):y=int(rnd(0)*24)+1
135 rem memory locations to poke
140 ml=k1+x+y*k2
150 mr=k1+(20+x)+y*k2
160 get a$ : if a$<>"" then 270
165 rem find location to 'unpoke'
170 if peek(ml)<>pl then 210
180 y=y+1 : if y<25 then 140
190 y=1 : x=x+1 : if x<20 then 140
200 x=0 : goto 140
210 if pl=k3 then nl=nl-kk : goto 230
220 nl=nl+kk
230 nr=ttl-nl : t=t+1
240 poke ml,pl : poke mr,pr
250 print chr$(19);nl;tab(17);"t=";kk*t;l$;tab(34);nr;l$
260 goto 80
265 rem reverse the arrow of time
270 kk=-kk : temp=k3 : k3=k4 : k4=temp
280 t=0 : goto 80